﻿using System.Web.UI;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Marbles.Core.Web.MVC.Views
{
    public abstract class NonModelView : ViewBase, INonModelView
    {

        public abstract void InitialiseView(object sender, ViewInitialiseEventArgs e);

        protected override void OnLoad(EventArgs e)
        {
            bool isAsyncRequest = false;

            if (!this.IsHeaderScriptIncludeRegistered("jQuery"))
            {
                Marbles.Core.Web.Resources.jQueryLibraryResource jQueryLibrary = new Marbles.Core.Web.Resources.jQueryLibraryResource();
                this.RegisterHeaderScriptInclude("jQuery", jQueryLibrary.jQueryResourceUrl);
                this.RegisterHeaderCSSInclude("jQueryCSS", jQueryLibrary.jQueryCSSResourceUrl);
            }

            if (this.Request["X-MicrosoftAjax"] != null)
            {
                if (this.Request["X-MicrosoftAjax"] == "delta-true") { isAsyncRequest = true; }
            }

            InitialiseView(this, new ViewInitialiseEventArgs(Page.IsPostBack, isAsyncRequest, Page.IsCallback));

            base.OnLoad(e);
        }

    }
}
